package com.company.project.controller.ldjsc.weather;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.company.project.entity.ldjsc.weather.ZyCityCodeJuheEntity;
import com.company.project.service.ldjsc.weather.ZyCityCodeJuheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.company.project.common.utils.DataResult;





/**
 * 城市代码（聚合）
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2025-07-24 09:44:41
 */
@Controller
@RequestMapping("/sxzy")
public class ZyCityCodeJuheController {
    @Autowired
    private ZyCityCodeJuheService zyCityCodeJuheService;


    /**
     * 空气质量（实时天气）城市名称列表
     */
    @GetMapping("/all/zyCityCodeJuhe")
    @ResponseBody
    public DataResult allCityCodeJuhe() {
        return DataResult.success(zyCityCodeJuheService.list());
    }


    /**
    * 跳转到页面
    */
    @GetMapping("/index/zyCityCodeJuhe")
    public String zyCityCodeJuhe() {
        return "zycitycodejuhe/list";
    }


    @ApiOperation(value = "查询分页数据")
    @PostMapping("zyCityCodeJuhe/listByPage")
    @SaCheckPermission("zyCityCodeJuhe:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody ZyCityCodeJuheEntity zyCityCodeJuhe){
        LambdaQueryWrapper<ZyCityCodeJuheEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        queryWrapper.eq(zyCityCodeJuhe.getId() != null, ZyCityCodeJuheEntity::getId, zyCityCodeJuhe.getId());
        queryWrapper.orderByDesc(ZyCityCodeJuheEntity::getId);
        IPage<ZyCityCodeJuheEntity> iPage = zyCityCodeJuheService.page(zyCityCodeJuhe.getQueryPage(), queryWrapper);
        return DataResult.success(iPage);
    }


    @ApiOperation(value = "新增")
    @PostMapping("zyCityCodeJuhe/add")
    @SaCheckPermission("zyCityCodeJuhe:add")
    @ResponseBody
    public DataResult add(@RequestBody ZyCityCodeJuheEntity zyCityCodeJuhe){
            zyCityCodeJuheService.save(zyCityCodeJuhe);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("zyCityCodeJuhe/delete")
    @SaCheckPermission("zyCityCodeJuhe:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
            zyCityCodeJuheService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("zyCityCodeJuhe/update")
    @SaCheckPermission("zyCityCodeJuhe:update")
    @ResponseBody
    public DataResult update(@RequestBody ZyCityCodeJuheEntity zyCityCodeJuhe){
            zyCityCodeJuheService.updateById(zyCityCodeJuhe);
        return DataResult.success();
    }



}
